package com.myiam.idm.meta.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;


@Entity
@Table(name="META_IDENTITY")
public class MmIdentity extends MmBase implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7132380854282491814L;

	@Id
	@GeneratedValue()
    @NotNull
	private long id;
	
	@Column
	private String firstName;
	
	@Column
	private String lastName;


	@OneToMany (cascade=CascadeType.ALL)
	private List<MmIdentityPhone> phones;
	

	@OneToMany (cascade=CascadeType.ALL)
	private List<MmIdentityEmail> emails;
		
	
	/*
	 * 
	 */
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public List<MmIdentityPhone> getPhones() {
		return phones;
	}
	
	public void addPhoneNumber(String phone ) {
		if (phones == null) {
			phones = new ArrayList<MmIdentityPhone>();
		}
		
		phones.add(new MmIdentityPhone(phone));
	}

	public void addEmail(String email,String type) {
		if (emails == null) {
			emails = new ArrayList<MmIdentityEmail>();
		}
		emails.add(new MmIdentityEmail(email,type));
	}
	
}
